package com.globant.dashboard.webapp.spring;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

import com.globant.dashboard.model.Language;
import com.globant.dashboard.model.Role;
import com.globant.dashboard.persist.HibernateSessionFactory;
import com.globant.dashboard.persist.UserDAO;
import com.globant.dashboard.persist.UserDAOImp;
import com.globant.dashboard.persist.UserValidator;
import com.globant.dashboard.service.UserService;
import com.globant.dashboard.service.UserServiceImp;



@Configuration
@EnableWebMvc 
@ImportResource({"/WEB-INF/applicationContext-security.xml","/WEB-INF/applicationContext-persist.xml"})
@ComponentScan(basePackages="com.globant.dashboard.webapp")
public class SpringBeans{

	
	@Bean
	public UserDAO userDAO(){
		return new UserDAOImp();
	}
	
	@Bean
	public HibernateSessionFactory hibernateSessionFactory(){
		return new HibernateSessionFactory();
	}
	
	@Bean
	public UserService userService(){
		return new UserServiceImp();
	}
	
	@Bean
	public UserValidator userValidator(){
		return new UserValidator();
	}
	
	@Bean Role roleUser(){
		return new Role("ROLE_USER");
	}
	
	@Bean Role roleAdmin(){
		return new Role("ROLE_ADMIN");
	}
	
	@Bean(name="spanish")
	public Language spanish(){
		return new Language("Spanish");
	}
	
	@Bean(name="english")
	public Language english(){
		return new Language("English");
	}
	
	@Bean(name="german")
	public Language german(){
		return new Language("German");
	}
	
	@Bean(name="french")
	public Language french(){
		return new Language("French");
	}
	
	@Bean(name="italian")
	public Language italian(){
		return new Language("Italian");
	}
}
